/*
 * Node.h
 *
 *  Created on: Nov 8, 2010
 *      Author: jacob
 */

#ifndef NODE_H_
#define NODE_H_
#include <string>
using std::string;

//REMOVE ME
#include <iostream>
using std::cout;

template<typename T>
class Node
{
public:
	static Node<T>* newNodeFromData(T nodesData);
	Node<T>* getNext();
	void setNext(Node<T>* next);
	T getData();
	void setData(T newData);
	string toString();
	Node();
	virtual ~Node();
private:
	Node<T>* next;
	T data;
	Node(T nodesData);
};

template<typename T>
Node<T>* Node<T>::newNodeFromData(T nodesData)
{
	return new Node<T> (nodesData);
}

template<typename T>
Node<T>::Node(T nodesData) :
	data(nodesData)
{
	//this->data = nodesData;
	this->next = NULL;
}

template<typename T>
Node<T>::Node()
{
	this->next = NULL;
	this->data = NULL;
}

template<typename T>
Node<T>::~Node()
{
	//cout << "\nNode " << this << "  Destructor Called";
	delete next;
}

template<typename T>
Node<T>* Node<T>::getNext()
{
	return this->next;
}

template<typename T>
void Node<T>::setNext(Node<T>* next)
{
	this->next = next;
}

template<typename T>
T Node<T>::getData()
{
	return this->data;
}

template<typename T>
void Node<T>::setData(T newData)
{
	this->data = newData;
}

template<typename T>
string Node<T>::toString()
{
	return data->toString();
}

#endif /* NODE_H_ */
